<%--
  Created by IntelliJ IDEA.
  User: finder
  Date: 2021/10/19
  Time: 9:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
    <script src="jquery-3.6.0.js"></script>
    <script>
      $(function () {
        $("input").keyup(function () {
          $.get("same",{name:$("input").val()},function(obj) {
            if(obj=="true"){
              $("span").removeClass("green");
              $("span").addClass("red");
              $("span").text("该用户名已被占用！");
            }else {
              $("span").removeClass("red");
              $("span").addClass("green");
              $("span").text("√");
            }
          }),"text"
        });
      });
    </script>
    <style>
      .red{
        color: red;
      }
      .green{
        color: green;
      }
    </style>
  </head>
  <body>
  <input type="text"><span></span>
  </body>
</html>
